﻿using Newtonsoft.Json;
using RestSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PW.Api.Model
{
    public class ResponseContent
    {
        public string msg;
        public int code;
        public string token;
        public object data;
        public object rows;
        public int total;
        public IRestResponse response;
        public Boolean isSuccess() {
            return code == 200;     
        }
        public List<T> getRows<T>()
        {
            if (rows == null) {
                return null;
            }
            return JsonConvert.DeserializeObject<List<T>>(rows.ToString());
        }
        public T getData<T>()
        {
            if (data == null)
            {
                return default(T);
            }
            return JsonConvert.DeserializeObject<T>(data.ToString());
        }
    }
}
